package office.excel.poi.utils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import office.excel.poi.core.impl.SheetImpl;


public class CellUtil {
	
	
	  /**
	   * 根据行内容得到行索引
	   * @param sheet
	   * @param rowName
	   * @return
	   */
	  public static int getBeginRowIndex(HSSFSheet sheet,String rowName)
	  {
		  HSSFCell c =  new SheetImpl().findCell(sheet,rowName);
		  try{ return c.getRowIndex();}catch (Exception e) {
		}
		  return -1;
		 
	  }
	  /**
	   * 根据列内容得到列索引
	   * @param sheet
	   * @param columnName
	   * @return
	   */
	  public static int getBeginColumnIndex(HSSFSheet sheet,String columnName)
	  {
		  HSSFCell c =  new SheetImpl().findCell(sheet,columnName);
		  try{
			return  c.getColumnIndex();
		  }catch (Exception e) {
		}
		  return -1;
	  }
	  /**
	   * 判断某列是否存在
	   * @param sheet
	   * @param columnName
	   * @return
	   */
	  public static boolean isExistColumn(HSSFSheet sheet,String columnName)
	  {
		  if(getBeginColumnIndex(sheet, columnName)>=0)return true;
		  return false;
	  }
}
